<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Gallery extends CI_Controller {

    	public function __construct(){

            parent::__construct();
            $this->load->helper('url');
        }

        public function index(){
            $this->load->model("Gallery_model");
            $data['pic_list']   = $this->Gallery_model->pic_list();
            $data['page'] = "gallery";
            $this->load->view('admin/dashboard', $data);
        }


        public function upload(){
            $this->load->model('Gallery_model');

            $upload_dir         = './uploads';
            $source_file        = $_FILES['userfile']['tmp_name'];
            $destination_file   = $_FILES['userfile']['name'];
            $file_type          = $_FILES['userfile']['type'];
                if (move_uploaded_file($source_file, $upload_dir."/". $destination_file)) {
                    $this->Gallery_model->uploader($destination_file,$file_type);
                    redirect ("admin/gallery");
//                echo "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']} - its type is {$_FILES['userfile']['type']}";


            }
            else {
                echo "Upload failed!";
            }


        }

            

}
?>
